<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改用户信息')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-userInfo-edit" th:object="${userInfo}">
        <input name="userId" th:field="*{userId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">账号：</label>
            <div class="col-sm-8">
                <input name="accountName" th:field="*{accountName}" class="form-control" type="text" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">手机号：</label>
            <div class="col-sm-8">
                <input name="phone" th:field="*{phone}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">身份证号：</label>
            <div class="col-sm-8">
                <input name="cardNo" th:field="*{cardNo}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">所属系统：</label>
            <div class="col-sm-8">
                <select name="sysId" id="sysId" th:with="item=${@dict.selectHiddenSysList()}" class="form-control"
                        required onchange="createProList()">
                    <option value="">所有</option>
                    <option th:each="dict : ${item}" th:text="${dict.sysName}"
                            th:value="${dict.sysId}" th:field="*{sysId}"></option>
                </select>
            </div>
        </div>
        <!--<div class="form-group">
            <label class="col-sm-3 control-label">所属单位：</label>
            <div class="col-sm-8">
                <input name="unitId" th:field="*{unitId}" class="form-control" type="text">
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">教育类型：</label>
            <div class="col-sm-8">
                <select name="eduLevel" th class="form-control m-b" th:with="type=${@dict.getType('learn_type')}" required>
                    <option value="">所有</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{eduLevel}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">所在岗位：</label>
            <div class="col-sm-8">
                <select name="postId" id="postId" class="form-control" required th:field="*{postId}">
                    <option value="">请选择岗位</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">工号：</label>
            <div class="col-sm-8">
                <input name="workNo" th:field="*{workNo}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">性别：</label>
            <div class="col-sm-8">
                <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                            th:field="*{sex}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">年龄：</label>
            <div class="col-sm-8">
                <input name="age" th:field="*{age}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">生日：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="birthday" th:value="${#dates.format(userInfo.birthday, 'yyyy-MM-dd')}"
                           class="form-control" placeholder="yyyy-MM-dd" type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">学历：</label>
            <div class="col-sm-8">
                <input name="education" th:field="*{education}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">民族：</label>
            <div class="col-sm-8">
                <input name="nation" th:field="*{nation}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('user_status')}">
                    <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}"
                           th:field="*{status}">
                    <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" th:field="*{remark}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "base/userInfo";
    $("#form-userInfo-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-userInfo-edit').serialize());
        }
    }

    $("input[name='birthday']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
    $(function () {
       var postId= [[${userInfo.postId}]]
        createProList(postId)
    })

    function createProList(postId) {
        var _postId = $("#postId").empty();
        _postId.append('<option value="">请选择岗位</option>')
        var val = $('#sysId  option:selected').val();
        if (val) {
            $.post(ctx + "/base/postInfo/queryPostList", {sysId: val}, function (res) {
                $.each(res, function (i, item) {
                    if (item.postId==postId){
                        _postId.append('<option value="' + item.postId + '" selected>' + item.postName + '</option>')
                    } else {
                        _postId.append('<option value="' + item.postId + '" >' + item.postName + '</option>')
                    }
                })
            })
        }
    }
</script>
</body>
</html>